
// -------------------------------------------------------------------------
/**
 *  Represents a single link of the linked list class. Holds a data element
 *  and a pointer to the next element in the list.
 *  @param <E>
 *
 *  @author Erik Rodriguez and Cory Chase
 *  @version Apr 12, 2013
 */
public class Link<E> {
	
	private Link<E> next = null;
	private E data = null;

	// ----------------------------------------------------------
	/**
	 * Create a new Link object.
	 * @param val
	 * @param nextLink
	 */
	public Link(E val, Link<E> nextLink){
		data = val;
		next = nextLink;
	}

	// ----------------------------------------------------------
	/**
	 * Create a new Link object.
	 * @param nextLink
	 */
	public Link(Link<E> nextLink){
		next = nextLink;
	}

	// ----------------------------------------------------------
	/**
	 * Return the next link
	 * @return the next
	 */
	public Link<E> next(){
		return next;
	}

	// ----------------------------------------------------------
	/**
	 * Change the next link
	 * @param nextLink
	 * @return the new next link
	 */
	public Link<E> setNext(Link<E> nextLink){
		return next = nextLink;
	}

	// ----------------------------------------------------------
	/**
	 * Return the data element
	 * @return the data
	 */
	public E getData(){
		return data;
	}

	// ----------------------------------------------------------
	/**
	 * Change the data element
	 * @param newData
	 */
	public void setData(E newData){
		data = newData;
	}


}
